package com.share.device.api;

import com.share.common.core.web.domain.AjaxResult;
import com.share.common.security.annotation.RequiresLogin;
import com.share.device.deviceConstant.DeviceConstants;
import com.share.device.domain.vo.StationVo;
import com.share.device.service.DeviceService;
import com.share.device.service.IStationService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.share.common.core.web.domain.AjaxResult.success;

@RestController
@RequestMapping("/device")
public class DeviceApiController {
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private IStationService stationService;
    @Operation(summary = "根据经纬度搜索附近门店（站点）")
    @RequiresLogin
    @GetMapping("/nearbyStation/{latitude}/{longitude}")
    public AjaxResult nearbyStation(@PathVariable String latitude, @PathVariable String longitude)
    {
        List<StationVo> stationVoList = deviceService.nearbyStation(latitude, longitude, DeviceConstants.SEARCH_H5_RADIUS);
        return success(stationVoList);
    }

}
